🧪 Mocks with `spec`

The `spec` parameter is a **powerful feature** that makes your mocks **safer and more realistic**. Let me explain with concrete examples.

## **What `spec` Does**

The `spec` parameter tells `Mock` **what attributes and methods** the mock object should have, based on a real class or object.

## **Without `spec` - Dangerous and Permissive**

```python
from unittest.mock import Mock

# Mock without spec - accepts ANYTHING
mock_engine = Mock()

# These all "work" even though they don'

Install development packages SteamOS

# Install packages steamOS

## Configure package manager
If you have not already, use ```passwd``` to create a password for the deck user.

Disable read-only mode: ```sudo steamos-readonly disable```

Initialize the ```pacman``` keyring: ```sudo pacman-key --init```

Populate the ```pacman``` keyring with the default Arch Linux keys: 
```
sudo pacman-key --populate archlinux
sudo pacman-key --populate holo
```

Try installing a package: ```sudo pacman -S vim```

## Install building packages
Inst

2410. Maximum Matching of Players With Trainers

You are given a 0-indexed integer array players, where players[i] represents the ability of the ith player. You are also given a 0-indexed integer array trainers, where trainers[j] represents the training capacity of the jth trainer. The ith player can match with the jth trainer if the player's ability is less than or equal to the trainer's training capacity. Additionally, the ith player can be matched with at most one trainer, and the jth trainer can be matched with at most one player. Return the maximum number of matchings between players and trainers that satisfy these conditions.
/**
 * @param {number[]} players
 * @param {number[]} trainers
 * @return {number}
 */
var matchPlayersAndTrainers = function(players, trainers) {
    // Step 1: Sort both arrays
    players.sort((a, b) => a - b);
    trainers.sort((a, b) => a - b);

    let i = 0; // pointer for players
    let j = 0; // pointer for trainers
    let matches = 0;

    // Step 2: Use two pointers to find valid matches
    while (i < players.length && j < trainers.length) {
        if (players[i] <= trainers[j]) {

deepseek api

sk-c440ee4bb5774594bbecf00559ece6d0

1900. The Earliest and Latest Rounds Where Players Compete

There is a tournament where n players are participating. The players are standing in a single row and are numbered from 1 to n based on their initial standing position (player 1 is the first player in the row, player 2 is the second player in the row, etc.). The tournament consists of multiple rounds (starting from round number 1). In each round, the ith player from the front of the row competes against the ith player from the end of the row, and the winner advances to the next round. When the number of players is odd for the current round, the player in the middle automatically advances to the next round. For example, if the row consists of players 1, 2, 4, 6, 7 Player 1 competes against player 7. Player 2 competes against player 6. Player 4 automatically advances to the next round. After each round is over, the winners are lined back up in the row based on the original ordering assigned to them initially (ascending order). The players numbered firstPlayer and secondPlayer are the best in the tournament. They can win against any other player before they compete against each other. If any two other players compete against each other, either of them might win, and thus you may choose the outcome of this round. Given the integers n, firstPlayer, and secondPlayer, return an integer array containing two values, the earliest possible round number and the latest possible round number in which these two players will compete against each other, respectively.
/**
 * Calculates the earliest and latest round two top players can meet in a knockout tournament.
 * @param {number} n - Total number of players.
 * @param {number} firstPlayer - The position of one top player.
 * @param {number} secondPlayer - The position of the other top player.
 * @return {number[]} - [earliestRound, latestRound]
 */
var earliestAndLatest = function(n, firstPlayer, secondPlayer) {
    // Normalize player positions: ensure lower < upper
    let lower = Math.min(firstPlayer, 

nintendo_emulator_Ryujinx

how to configure ryuinx:
https://www.youtube.com/watch?v=W6gMjpuMvcs&t=187s

nintento_emulator_yuzu

nintendo roms:
https://fmhy.net/gamingpiracyguide#nintendo-roms
https://romslab.com/untitled-goose-game-switch-nsp-free-download/

Exemple installation module depuis console python de qgis

import subprocess
subprocess.check_call(['pip', 'install', 'opencv-python', 'pytesseract', 'easyocr', 'pillow'])

Python Env Vars

# Common file for reusing ENV Vars
* `pip install dotenv`
* create `.env` file with variables defined:
  * `name=somevavlue`
```python
# config.py
import os
from dotenv import load_dotenv

class Config():
  API_URL = os.getenv(name)
  
# import from another file
from config import Config

name = Config.name
```

2402. Meeting Rooms III

You are given an integer n. There are n rooms numbered from 0 to n - 1. You are given a 2D integer array meetings where meetings[i] = [starti, endi] means that a meeting will be held during the half-closed time interval [starti, endi). All the values of starti are unique. Meetings are allocated to rooms in the following manner: Each meeting will take place in the unused room with the lowest number. If there are no available rooms, the meeting will be delayed until a room becomes free. The delayed meeting should have the same duration as the original meeting. When a room becomes unused, meetings that have an earlier original start time should be given the room. Return the number of the room that held the most meetings. If there are multiple rooms, return the room with the lowest number. A half-closed interval [a, b) is the interval between a and b including a and not including b.
/**
 * @param {number} n
 * @param {number[][]} meetings
 * @return {number}
 */
var mostBooked = function(n, meetings) {
    // Initialize arrays to track the number of bookings and the end times of the last meetings for each room
    const count = new Array(n).fill(0);
    const roomEndTimes = new Array(n).fill(0);

    // Sort meetings by start time
    meetings.sort((a, b) => a[0] - b[0]);

    // Iterate through each meeting
    for (const [start, end] of meetings) {
        let assigned = 

Backup Full Database Script as Procedure

CREATE OR ALTER PROCEDURE [dbo].[usp_BackupDatabaseFull]
    @DbName SYSNAME,
    @BackupFolder NVARCHAR(255) = 'K:\SQLBackups\'  -- Default path; override if needed
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE 
        @BackupFile NVARCHAR(500),
        @Timestamp NVARCHAR(50),
        @sql NVARCHAR(MAX);

    -- Check if database exists
    IF NOT EXISTS (SELECT 1 FROM sys.databases WHERE name = @DbName)
    BEGIN
        RAISERROR('Database [%s] does not exist.', 16, 1, @DbName);

JS - Pars Form Data

parsFormData() {
  return [...new FormData(this.form)].reduce((acc, [name, value]) => ({...acc, [name]: value}), {});
}

#parseFormData() {
  // Efficiently convert FormData to object
  return Object.fromEntries(new FormData(this.#form));
}

Reexport ES exports

// index.js
export * as MathUtils from "./math.js";
export * as StringUtils from "./string-utils.js";

// Usage:
// import { MathUtils, StringUtils } from './index.js';





// modules/index.js
export { default as Calculator } from "./calculator.js";
export { default as Logger } from "./logger.js";
export * from "./math.js";
export * from "./string-utils.js";
export { ApiClient as Client, HTTP_METHODS as Methods } from "./config.js";

ES6 dynamic import / export

// app.js

async function loadMathModule() {
  const mathModule = await import("./math.js");
  console.log(mathModule.add(5, 3));
}

// Or with .then()
import("./math.js")
  .then((mathModule) => {
      console.log(mathModule.PI);
  })
  .catch((error) => {
      console.error("Failed to load module:", error);
  });

[WP] 親と子孫のカテゴリを表示

<?php
# 親 & 子孫カテゴリを別途表示
// カレント機能は連携させて持たせる

// 現在のタームとその最上位の親を取得
$current_term = null;
$top_parent_id = 0;
if($_term_slug) {
    $current_term = get_term_by('slug', $_term_slug, $_post_type_slug.'category');
    if($current_term && !is_wp_error($current_term)) {
        // 最上位の親を見つける
        $temp_term = $current_term;
        while($temp_term->parent != 0) {
            $temp_term = get_term($temp_term->parent, $_post_type_slug.'category');
            if(is_wp_error($temp_term)) break;
      

charles使用技巧

# charles使用技巧
## 导出session
- **导出所有session:**`File` -> `Save session`
- **导出单个session:**选中单个session -> 右键`Export Session`